<?
include("session.php");

$default_start_date = date("Y")."-01-01";
//$default_start_date = date("Y-m-d", strtotime("-1 year"));
$default_end_date = date("Y-m-d");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/webkit/utils/jquery.js"></script>
<script type="text/javascript" src="/webkit/dialog/import.js"></script>
<script type="text/javascript" src="/webkit/datepicker/WdatePicker.js"></script>
<script type="text/javascript" src="/webkit/charts/import.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/>
<style>	input {vertical-align:middle} </style>
</head>
<body onload="show_report_charts()">

<table width=100% height=100% cellspacing=0 cellpadding=0>
	<tr bgcolor="#eeeeee">
	<form name=f>
	<td height=30>&nbsp;
    时间范围：<input type="text" value="<? echo $default_start_date?>" id="date_start" name="date_start" onClick="WdatePicker({readOnly:true, skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" size="10"> - <input type="text" value="<? echo $default_end_date?>" id="date_end" name="date_end" onClick="WdatePicker({readOnly:true, skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" size="10">　
	<input type="button" value="图表统计" onclick="show_report_charts()">　　
	<a href="javascript:show_report_page('si_money_sum.php')">SI结算汇总</a> |　<a href="javascript:show_report_page('si_money_detail_client.php')">SI结算明细(客户)</a> |　<a href="javascript:show_report_page('si_money_detail_area.php')">SI结算明细(区域)</a> |　<a href="javascript:show_report_page('si_money_detail_agent.php')">代理分成明细</a>
    </td>
	</tr>
	<tr>
	<td>
		<table width=100% height=100% id="chartsTable">
		<tr><td id="chartContainer1" width=50%></td><td id="chartContainer2"  width=50%></td></tr>
		<tr><td id="chartContainer3" width=50%></td><td id="chartContainer4"  width=50%></td></tr>
		</table>

		<table width=100% height=100% id="pageTable" style="display:none" cellpadding=0 cellspacing=0>
		<tr><td><iframe frameborder=0 name="pageFrame" width=100% height=100% marginheight=0 marginwidth=0 scrolling=auto></iframe></td></tr>
		</table>
	</td>
	</form>
	</tr>
</table>

<script type="text/javascript">

	var agentsChart = new FusionCharts("/webkit/charts/Pie3D.swf",  "agentsChart", "100%", "100%", "0", "1" );     
	var provincesChart = new FusionCharts("/webkit/charts/Pie3D.swf",  "provincesChart", "100%", "100%", "0", "1" );     
	//var moneyChart = new FusionCharts("/webkit/charts/Line.swf",  "monthChart", "100%", "100%", "0", "1" );   
	//var typeReport = new FusionCharts("/webkit/charts/Column3D.swf", "monthReport", "100%", "100%", "0", "1"); 
	var moneyChart = new FusionCharts("/webkit/charts/Pie3D.swf",  "monthChart", "100%", "100%", "0", "1" );   
	var serviceTypeReport = new FusionCharts("/webkit/charts/Pie3D.swf", "serviceTypeReport", "100%", "100%", "0", "1"); 
	var clientTypeReport = new FusionCharts("/webkit/charts/Pie3D.swf", "clientTypeReport", "100%", "100%", "0", "1"); 

	function show_report_charts() {
		$("#pageTable").hide();
		$("#chartsTable").show();

		$.get("report_query.php?action=agents_report"+ get_date_range(), function(data){
			eval("var json = "+data);
			agentsChart.setJSONData(json);
			agentsChart.render('chartContainer1');  
		});

		$.get("report_query.php?action=provinces_report"+ get_date_range(), function(data){
			eval("var json = "+data);
			provincesChart.setJSONData(json);
			provincesChart.render('chartContainer2');  
		});

		$.get("report_query.php?action=money_report"+ get_date_range(), function(data){
			eval("var json = "+data);
			moneyChart.setJSONData(json);
			moneyChart.render('chartContainer3');  
		});

		/*$.get("report_query.php?action=service_type_report"+ get_date_range(), function(data){
			eval("var json = "+data);
			serviceTypeReport.setJSONData(json);
			serviceTypeReport.render('chartContainer4');  
		});*/

		$.get("report_query.php?action=client_type_report"+ get_date_range(), function(data){
			eval("var json = "+data);
			clientTypeReport.setJSONData(json);
			clientTypeReport.render('chartContainer4');  
		});
	}

	function get_date_range() {
		return "&date_start="+ $("#date_start").val() + "&date_end=" + $("#date_end").val();
	}

    function show_client_list_by_area(n) {
		//alert(n)
	}

	function show_report_page(url) {
		$("#pageTable").show();
		$("#chartsTable").hide();
		window.frames['pageFrame'].location = url+"?t="+new Date().getTime();
	}

</script>
</body>
</html>
